#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/2/1 17:54
# @Author  : huidong.bai
# @File    : MongoConfig.py
# @Software: PyCharm
# @Mail    : MasterBai2018@outlook.com
import yaml
from enum import Enum, unique

# 相对/绝对时间戳的配置, True为绝对时间戳，False为相对时间戳
ABS_TIMESTAMP = True


# 目前支持的TestSuit, 需要在这里添加
@unique
class AvailableSuite(Enum):
    FUNCTION = "src/testsuite/24mm/TSAP/Function/test_function.py"
    NLU = "src/testsuite/24mm/TSAP/Function/test_nlu.py"
    CARPLAY = "src/testsuite/24mm/TSAP/Function/test_carplay.py"
    ECNR = "src/testsuite/24mm/TSAP/Function/test_ecnr.py"
    VOI = "src/testsuite/24mm/TSAP/Function/test_voice_input.py"
    HMI_STABILITY = "src/testsuite/24mm/TSAP/Stability/test_hmi_stability.py"
    HAWKDECODER = "src/testsuite/24mm/HawDecoder/test_hawkdecoder.py"
    BOUNDARY = "src/testsuite/24mm/TSAP/Function/test_boundary_delta.py"
    REFUSAL = "src/testsuite/24mm/TSAP/Function/test_refusal.py"

    VOICE_PRINT = "src/testsuite/24mm/TSAP/Function/test_voice_print.py"
    ROUTINE = "src/testsuite/test_routine.py"
    SEARCH = "src/testsuite/test_search.py"
    PERFORMANCE_ASR_RATE = "src/testsuite/performance/asr/test_performance_asr_rate.py"
    PERFORMANCE_WAKEUP_LONG_RATE = "src/testsuite/performance/wakeup/test_performance_wakeup_longtime_rate.py"
    PERFORMANCE_VOICEPRINT = "src/testsuite/24mm/TSAP/Performance/test_voice_print_performance.py"

    PERFORMANCE_LOCAL_ASR_TIME_BOUNDARY = "src/testsuite/24mm/HawDecoder/test_local_asr_time_boundary.py"
    PERFORMANCE_LOCAL_ASR_TIME_BOUNDARY_LONG = "src/testsuite/24mm/HawDecoder/test_local_asr_time_boundary_long.py"
    PERFORMANCE_WAKEUP_ACCURACY_LONG = "src/testsuite/24mm/HawDecoder/test_hawkdecoder_wakeup_long_accuracy.py"
    LOCAL_DELAY_SUITE = "src/testsuite/24mm/HawDecoder/test_hawk_local_delay.py"
    PSTT = "src/testsuite/24mm/PSTT/test_pstt.py"
    PSTT_ASYNCIO = "src/testsuite/24mm/PSTT/test_pstt_asyncio.py"
    PSTT_DELAY = "src/testsuite/24mm/PSTT/test_pstt_delay.py"
    FUNCTION_ASR_DELAY = "src/testsuite/24mm/TSAP/Performance/test_function_delay.py"



AvailableSuite.FUNCTION.summary = "通用测试Suite"
AvailableSuite.VOICE_PRINT.summary = "声纹测试Suite"
AvailableSuite.CARPLAY.summary = "CarPlay测试Suite"
AvailableSuite.NLU.summary = "理解垂类测试Suite"
AvailableSuite.VOI.summary = "语音输入法测试Suite"
AvailableSuite.ROUTINE.summary = "自定义流程测试Suite"
AvailableSuite.ECNR.summary = "ECNR软降噪测试Suite"
AvailableSuite.SEARCH.summary = "复合搜索测试Suite"
AvailableSuite.PERFORMANCE_ASR_RATE.summary = "识别率性能测试Suite"
AvailableSuite.PERFORMANCE_WAKEUP_LONG_RATE.summary = "唤醒长音频唤醒率测试Suite"
AvailableSuite.HMI_STABILITY.summary = "HMI稳定性测试Suite"
AvailableSuite.PSTT.summary = "云端PSTT测试Suite"
AvailableSuite.PSTT_DELAY.summary = "云端PSTT-Delay测试Suite"
AvailableSuite.BOUNDARY.summary = "本地云端边界计算"
AvailableSuite.REFUSAL.summary = "拒识测试Suite"
AvailableSuite.PSTT_ASYNCIO.summary = "PSTT多路并行Suite"
AvailableSuite.PERFORMANCE_LOCAL_ASR_TIME_BOUNDARY.summary = "本地识别时间边界性能测试SUITE"
AvailableSuite.PERFORMANCE_LOCAL_ASR_TIME_BOUNDARY_LONG.summary = "本地识别长音频时间边界性能测试SUITE"
AvailableSuite.PERFORMANCE_WAKEUP_ACCURACY_LONG.summary = "本地唤醒长音频唤醒率性能测试SUITE"
AvailableSuite.PERFORMANCE_VOICEPRINT.summary = "声纹性能测试Suite"
AvailableSuite.LOCAL_DELAY_SUITE.summary = "本地时延测试Suite"
AvailableSuite.FUNCTION_ASR_DELAY.summary = "端到端时延测试Suite"

# 可支持的输入字段
INPUT_KEYS = {
    "id",             # ID编号，记录需求
    "voice",          # 输入音频
    "voiceList",      # 输入音频列表，后跟文件列表
    "srVoice",        # 声纹注册音频
    "text",           # 输入文本
    "event",          # 输入事件
    "eventList",      # 输入事件列表
    "vrEvent",      # vr设置项设置事件
    "inputEvent",     # 理解事件输入
    "callbackEvent",  # 回调事件输入

    # tts合成参数
    "audioText",       # 文本TTS音频
    "ttsLang",         # TTS合成参数，ttsLang:cmn/eng/chuan

    # ECNR输入项
    "speech",       # 语音发话片段

    # 声纹性能输入项
    "enrollVoicePath",  # 声纹注册音频路径
    "verifyPath",       # 声纹验证音频路径
    "sreTestSet",       # 声纹性能测试Suite
}

# 可支持的参数输入字段
PARAM_KEYS = {
    # Mongo配置参数
    "shape",        # 音频形状
    "delay",        # 是否delay送
    "textDelay",    # 送文本前的Delay时间
    "useNR",        # 是否使用软降噪
    "cancel",       # cancel调用时间
    "dialog",       # 控制上下文流程，start--流程开始，end--流程结束，默认为单轮交互

    # SpeechEngine配置参数
    "workMode",     # 工作模式
    "wakeupScene",  # 场景唤醒设置
    "nickName",     # 自定义唤醒词设置
    "threshold",    # 唤醒词阈值设置
    "delayOneshotDuration", # OneShot的duration超时
    "linkType",             # 智能联协模式设置
    "wakeupWordOnline",     # 设置唤醒词上线
    "wakeupWordOffline",    # 设置唤醒词下线
    "wakeupWordDisable",    # 删除唤醒词
    "silence_duration",     # 静音超时设置
    "wakeupSceneEnable",    # 场景唤醒词开关
    "digitOption",          # 数字转换开关
    "offlineButterfly",     # 离线实时上屏开关

    # # LCS配置参数
    "strategy",             # 策略, 1 在线，0离线，2混合
    "bluetooth",            # 蓝牙连接状态
    "freeWakeup",           # Freewakeup开关， 1不需要唤醒能直接识别，0表示需要唤醒之后才能识别
    "fullTimeOption",       # 全时回话开关，1表示开，0表示关
    "keepDialogue",         # 设置回话保持开关，1表示开启，0表示关闭
    "parallelSR",           # 协同/并行模式设置，1表示并行，0表示协同
    "freetalkTimeout",      # 设置freetalk超时时长
    "srMode",               # 设置识别模式，单段，多段

    # LCS和SpeechEngine同时设置
    "tts",          # tts播报状态
    "lang",         # 语种信息
    "grammar",      # 个性化信息设置
    "hmi",          # 可见即可说设置信息
    "pttOption",    # 主驾锁定
    "seatSignal",   # 设置坐席信号
    "linkType",     # 设置LinkType

    # CarPlay配置项
    "carplay",        # carplay模式
    "carplayMode",    # carplay回调模式
    "carplayLang",    # carplay语言
    "carplayStatus",  # carplay识别状态
    "linkType",       # HiCar链接状态

    # 声纹配置项
    "srText",           # 声纹注册文本
    "srChannel",        # 声纹注册ChannelId
    "srUserId",         # 声纹注册userid
    "srIndex",          # 声纹注册次数
    "checkSrUser",      # 查询声纹user
    "delSrUser",        # 删除声纹user
    "sreOption",        # 声纹使能开关
    "sreSensitiveWord", # 声纹铭感次检测

    # 语音输入法配置项
    "voiChannel",       # 语音输入法音区
    "voiMode",          # 语音输入法模式
    "voiSilDuration",   # 语音输入法silence duration
    "voiScene",         # 语音输入法场景

    # VR配置项
    "vrLang",                     # 语种信息：离线支持4选1（普，粤，川，英），默认普通话
    "vrWakeupWord",               # 设置唤醒词，默认主唤醒词"你好XX"
    "vrDialogueMode",             # 设置对话模式：1--连续对话, 2--全时对话，默认连续
    "vrSeatSignal",               # 设置音区，默认主驾：0--所有音区都无法使用，1--主驾可用，2--副驾可用，4--第二排右侧音区可用，8--第二排>左侧音区可用，16--第三排右侧音区可用，32--第三排左侧音区可用
    "vrSceneOption",              # 设置场景唤醒词开关：0--禁用，1：启用，默认打开
    "vrReset",                    # 恢复出厂设置，value:1
    "vrWakeupAlias",              # 设置唤醒词别名
    "vrOption",                   # 设置唤醒词开关
    "vrActiveInteractionOption",  # 设置主动交互开关配置
    "vrPrintption",               # 设置声纹隐私开关
    "dataType",                   # HawkDecoder SpeechEngine 设置音频类型的参数, 0: 单声道, 1:降噪后多声道, 2:未降噪原始音频

    # ECNR配置项
    "micNum",           # 麦克风声道数量: 4
    "refNum",           # 参考声道数量: 7
    "micDistance",      # 麦克风间距: 646
    "device",           # 设备类型: lexus_2S
    "sampleRate",       # 采样率: 16000
    "nrWorkMode",       # 软降噪工作模式
    "muteOption",       # 静音模式, 0关闭静音, 1开启静音
    "enableOption",     # ECNR开关, 0关闭, 1打开
    "channelMask",      # ECNR输出声道，1代表一声道
    "synthMethod",      # ECNR音频处理方式，1--只针对主驾降噪；2--针对channelMask声道降噪，输出channelMask所有声道；3--针对channelMask声道降噪，合并输出一个声道
    "output",           # ECNR输出的路径
    "spectrum",         # vscoder参数设置
    "downLink",         # 是否为下行参数设置

    # 声纹性能测试Suite配置
    "threshold",        # 声纹阈值
    "loop",             # 循环数
    "register",         # 注册数
    "outside",          # 集外人数
    "relate",           # 文本相关和无关配置

    # PSTT配置
    "audioType",        # 音频格式
    "digit",            # 数字转换开关
    "punct",            # 标点符号开关
    "gender",           # 性别开关
    "age",              # 年龄开关
    "emotion",          # 情绪开关
    # 时间边界容忍值性能
    "tolerance",        # 时间边界容忍值
    # pstt多路并发
    "ip",          # pstt服务地址
    "port",          # pstt服务端口
    "cport",          # pstt服务端口cport
    "resourse_name",          # pstt资源名
    "audio_type",          # pstt音频类型
    "thread_num",          # pstt并发数量
    "is_ask_trans_digit",
    "is_ask_add_punct",
    "is_ask_butterfly",
    "gender_option",
    "emotion_option",
    "age_option",
    "overlap_option",
}


typeMapple = {
    "NLP": "NLPResult",             # 理解结果断言
    "ASR": "ASRResult",             # 识别结果断言
    "ATP": "ASRResultTemp",         # 临时识别结果断言
    "VOI": "ASRInputResult",        # 语音输入法识别结果断言
    "VTP": "ASRInputResultTemp",    # 语音输入法临时识别结果断言
    "API": "API",                   # 接口Code返回值断言
    "HIC": "HICARWakeup",           # HiCar唤醒断言
    "CPL": "CarPlay",               # CarPlay唤醒断言
    "PSTT": "PSTTResult",           # PSTT测试结果
}
